package leetcode81_90;

import outoforder.leetcode.ListNode;

/**
 * @author shhjiang_001
 * @create 2020-06-24 10:39
 */
                /*
                给定一个排序链表，删除所有含有重复数字的节点，只保留原始链表中 没有重复出现 的数字。
                示例 1:
                输入: 1->2->3->3->4->4->5
                输出: 1->2->5
                */

public class Solution82 {
    public ListNode deleteDuplicates(ListNode head) {
        ListNode resLN = new ListNode();
        ListNode temp = resLN;
        int lastValue = head.val-1;
        while (head.next != null){
            if ( head.val < head.next.val && head.val > lastValue){
                temp.next = new ListNode();
                temp = temp.next;
                temp.val = head.val;
            }
            lastValue = head.val;
            head = head.next;
        }
        if (head.next == null && head.val > lastValue){
            temp.val = head.val;
        }

        return resLN.next;

    }

}
